<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">

    <ui:define name="content">
        <p:menubar model="#{staffChangeInitialPasswordManagedBean.staffMenuModel}"/>
        <h:form>
            <p:fieldset>
                <h2>View Groupon Applications (Double click to select)</h2>
                <p:accordionPanel autoHeight="false">
                    <p:tab title="Pending Applications">
                        <p:dataTable var="pendingApplication" value="#{grouponManagerBean.tCubePendingGrouponApplicationList}" paginator="true" 
                                     rows="10" emptyMessage="No pending application" selection="#{grouponManagerBean.selectedGrouponApplication}" 
                                     selectionMode="single" rowSelectListener="#{grouponManagerBean.onRowTCubeSelectNavigateGrouponApplication}"
                                     dblClickSelect="true">
                            <p:column sortBy="#{pendingApplication.id}" filterBy="#{pendingApplication.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.id}" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.stakeholder.corpName}" filterBy="#{pendingApplication.stakeholder.corpName}">
                                <f:facet name="header">
                                    <h:outputText value="Company name" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.stakeholder.corpName}" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.name}" filterBy="#{pendingApplication.name}">
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.name}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Image" />
                                </f:facet>
                                <p:graphicImage id="imageDisplay" value="/images/upload/media/#{pendingApplication.imageURL}"
                                                height="50" width="70"/> 
                            </p:column>  

                            <p:column sortBy="#{pendingApplication.offeredPrice}" filterBy="#{pendingApplication.offeredPrice}">
                                <f:facet name="header">
                                    <h:outputText value="Offered Price" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.offeredPrice} SGD" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.minimumIssuedQuantity}" filterBy="#{pendingApplication.minimumIssuedQuantity}">
                                <f:facet name="header">
                                    <h:outputText value="Minumum Quantity" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.minimumIssuedQuantity}" />
                            </p:column>

                            <p:column sortBy="#{pendingApplication.startDate}" filterBy="#{pendingApplication.startDate}">
                                <f:facet name="header">
                                    <h:outputText value="Start Selling Date" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.startDate}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{pendingApplication.endDate}" filterBy="#{pendingApplication.endDate}">
                                <f:facet name="header">
                                    <h:outputText value="End Selling Date" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.endDate}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{pendingApplication.status}" filterBy="#{pendingApplication.status}">
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{pendingApplication.status}" />
                            </p:column>

                        </p:dataTable>
                    </p:tab>

                    <p:tab title="All groupon applications">
                        <p:dataTable var="grouponApplication" value="#{grouponManagerBean.tCubeGrouponApplicationList}" paginator="true" 
                                     rows="10" emptyMessage="No pending application" selection="#{grouponManagerBean.selectedGrouponApplication}" 
                                     selectionMode="single" rowSelectListener="#{grouponManagerBean.onRowTCubeSelectNavigateGrouponApplication}"
                                     dblClickSelect="true">

                            <p:column sortBy="#{grouponApplication.id}" filterBy="#{grouponApplication.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.id}" />
                            </p:column>

                            <p:column sortBy="#{grouponApplication.stakeholder.corpName}" filterBy="#{grouponApplication.stakeholder.corpName}">
                                <f:facet name="header">
                                    <h:outputText value="Company name" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.stakeholder.corpName}" />
                            </p:column>

                            <p:column sortBy="#{grouponApplication.name}" filterBy="#{grouponApplication.name}">
                                <f:facet name="header">
                                    <h:outputText value="Name" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.name}" />
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Image" />
                                </f:facet>
                                <p:graphicImage id="imageDisplay" value="/images/upload/media/#{grouponApplication.imageURL}"
                                                height="50" width="70"/> 
                            </p:column>

                            <p:column sortBy="#{grouponApplication.offeredPrice}" filterBy="#{grouponApplication.offeredPrice}">
                                <f:facet name="header">
                                    <h:outputText value="Offered Price" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.offeredPrice} SGD" />
                            </p:column>

                            <p:column sortBy="#{grouponApplication.minimumIssuedQuantity}" filterBy="#{grouponApplication.minimumIssuedQuantity}">
                                <f:facet name="header">
                                    <h:outputText value="Minimum Quantity" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.minimumIssuedQuantity}" />
                            </p:column>

                            <p:column sortBy="#{grouponApplication.startDate}" filterBy="#{grouponApplication.startDate}">
                                <f:facet name="header">
                                    <h:outputText value="Start Selling Date" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.startDate}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{grouponApplication.endDate}" filterBy="#{grouponApplication.endDate}">
                                <f:facet name="header">
                                    <h:outputText value="End Selling Date" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.endDate}">
                                    <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                </h:outputText>
                            </p:column>

                            <p:column sortBy="#{grouponApplication.status}" filterBy="#{grouponApplication.status}">
                                <f:facet name="header">
                                    <h:outputText value="Status" />
                                </f:facet>
                                <h:outputText value="#{grouponApplication.status}" />
                            </p:column>
                        </p:dataTable>
                    </p:tab> 
                </p:accordionPanel> 
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>